package com.bdqn.t320.service;

import com.bdqn.t320.dao.SysUserMapper;
import com.bdqn.t320.pojo.SysUser;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SysUserServiceImp implements SysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }

    @Override
    public List<SysUser> getUserListBiz() {
        return sysUserMapper.getUserList();
    }


    @Override
    public int add(SysUser sysUser) {
        return sysUserMapper.add(sysUser);
    }

    @Override
    public boolean adds(List<SysUser> list) {
        boolean result = true;
        try {
            for (SysUser sysUser : list) {
                if (sysUserMapper.add(sysUser) < 1) {
                    result = false;
                }
                //System.out.println(1 / 0);
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = false;
            throw e;
        }
        return result;
    }
}

